/******************************************************************************
 * FileName:    gwin_general_timer.h
 * Desc:        通用定时器
 *                  循环判断的定时器
 *
 * Author:      Lin
 * Notes:
 *
 ******************************************************************************/

#ifndef __GWIN_GENERAL_TIMER_H__
#define __GWIN_GENERAL_TIMER_H__


/*-------------------------- Includes ---------------------------------------*/
#include "stdint.h"


/*-------------------------- Macro Definitions ------------------------------*/
#define GWIN_GENERAL_TIMER_CNT_MAX                      ( 8 )


/*-------------------------- Type Declarations ------------------------------*/
typedef struct
{
//    const char *name;               // 名字，方便调试打印
//    uint32_t period_time;           // 周期时间，单位ms
//    void *arg;                      // 传入参数
    void (*callback)(void *arg);    // 超时回调
    uint32_t start_time;            // 起始时间，单位ms
    uint32_t used           : 1;    // 占用位
    uint32_t repeat         : 1;    // 是否循环
    uint32_t period_time    :30;    // 周期时间，单位ms
}gwin_general_timer_ctrl_t;


/*-------------------------- Global Variables -------------------------------*/

/*-------------------------- Local Variables --------------------------------*/

/*-------------------------- Functions Declarations -------------------------*/

/*-------------------------- Functions Definitions --------------------------*/
void gwin_general_timer_handle(void);

gwin_general_timer_ctrl_t *gwin_general_timer_create(const char *name, uint32_t period_time, uint8_t repeat, void *arg, void (*callback)(void *arg));
uint8_t gwin_general_timer_start(gwin_general_timer_ctrl_t *timer);
uint8_t gwin_general_timer_stop(gwin_general_timer_ctrl_t *timer);
uint8_t gwin_general_timer_delete(gwin_general_timer_ctrl_t *timer);
uint8_t gwin_general_timer_is_active(gwin_general_timer_ctrl_t *timer);


#endif // __GWIN_GENERAL_TIMER_H__


/*-------------------------- END OF FILE ------------------------------------*/

